/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Library;

import java.io.IOException;
import java.io.StringWriter;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.JspFragment;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 *
 * @author Cyrax
 */
public class UpperTag extends SimpleTagSupport {

    @Override
    public void doTag() throws JspException, IOException {
        JspFragment bodyContent = getJspBody();
        JspWriter out = getJspContext().getOut();

        StringWriter stringWriter = new StringWriter();
        bodyContent.invoke(stringWriter);
        if (stringWriter.toString().length() > 40) {
            out.println(stringWriter.toString().substring(0, 20));
        } else {
            out.println(stringWriter.toString());
        }
    }
}
